package com.cskaoyan.service;

import com.cskaoyan.bean.User;
import com.cskaoyan.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{

    //如果我想这样使用，容器中要有UserMapper这样的组件
    //这个组件的获得，一定是和SqlSessionFactory相关的
    @Autowired
    UserMapper userMapper;

    @Override
    public User queryUserById(Integer id) {

        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public int addUser(User user) {
        return userMapper.insert(user);
    }

    @Override
    public int addDoubleUser(User user1, User user2) {
        userMapper.insert(user1);
        int i = 1 / 0;
        userMapper.insert(user2);
        return 0;
    }
}
